package test.administrator.example.com.mobileshop.utils;

import android.content.Context;
import android.content.res.AssetManager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Tools {
    /*
    读取assets文件夹中的数据
     */
    public static String getAssetsFile(Context context, String fileName) {
        StringBuffer stringBuffer = new StringBuffer();
        try {
            AssetManager assetManager = context.getAssets();
            BufferedReader bf = new BufferedReader(new InputStreamReader((assetManager.open(fileName))));
            String line;
            while ((line = bf.readLine()) != null) {
                stringBuffer.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuffer.toString();

    }
}
